<?php

class Application_Model_CaptchaValidator
{

    public function init()
    {
        /* Initialize action controller here */
    }


    //validates captcha response
    function validateCaptcha($captcha) {
        
        $captchaId = $captcha['id'];
        $captchaInput = $captcha['input'];
        $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaId);
        $captchaIterator = $captchaSession->getIterator();

        if (count($captchaIterator) > 0){
            $captchaWord = $captchaIterator['word'];

            if( $captchaWord ) {
                if( $captchaInput != $captchaWord ){
                    return false;
                } else {
                    return true;
                }
            } else {
                return false;
            }
        }else{
            return false;
        }
    }



}

